<%--
  Created by IntelliJ IDEA.
  User: hasee
  Date: 2017/10/27
  Time: 15:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<h1 align="center">商品列表</h1>
<form action="${pageContext.request.contextPath}/productListServlet" method="get">
    <table align="center" width="50%">
        <tr>
            <td><input type="text" name="condition" value=""><input type="submit" value="搜索"></td>
        </tr>
    </table>
</form>

<div align="center"><a href="${pageContext.request.contextPath}/product/addproductlist.jsp">添加</a></div>

<form action="${pageContext.request.contextPath}/productListServlet" method="get">
    <table border="1" align="center" width="50%">
        <tr>
            <td>序号</td>
            <td>商品名称</td>
            <td>价格</td>
            <td>操作</td>
        </tr>
        <c:forEach items="${pageBean.list}" var="product" varStatus="status">
            <tr>
                <td>${status.count+((pageBean.pageNum-1)*pageBean.listLimit)}</td>
                <td>${product.pname}</td>
                <td>${product.shopPrice}</td>
                <td>
                    <a href="${pageContext.request.contextPath}/editUIServlet?pid=${product.pid}?&pageNum=${pageBean.pageNum}&condition=${pageBean.condition}">修改</a>|
                    <a href="${pageContext.request.contextPath}/removeProductServlet?pid=${product.pid}?&pageNum=${pageBean.pageNum}&condition=${pageBean.condition}" onclick="return confirm('确定要删除该商品吗?')">删除</a>
                </td>
            </tr>
        </c:forEach>
    </table>
</form>
<div align="center">
    <p>
        <a href="${pageContext.request.contextPath}/productListServlet?pageNum=1&condition=${pageBean.condition}">首页</a>&nbsp
        <c:if test="${pageBean.pageNum-1>0}">
            <a href="${pageContext.request.contextPath}/productListServlet?pageNum=${pageBean.pageNum-1}&condition=${pageBean.condition}">上一页</a>&nbsp
        </c:if>
        <c:if test="${pageBean.pageNum+1<=pageBean.totalPageNum}">
            <a href="${pageContext.request.contextPath}/productListServlet?pageNum=${pageBean.pageNum+1}&condition=${pageBean.condition}">下一页</a>&nbsp
        </c:if>
        <a href="${pageContext.request.contextPath}/productListServlet?pageNum=${pageBean.totalPageNum}&condition=${pageBean.condition}">尾页</a>&nbsp
    </p>
    <p>
        <c:if test="${pageBean.pageNum-2>0}"><a href="${pageContext.request.contextPath}/productListServlet?pageNum=${pageBean.pageNum-2}&condition=${pageBean.condition}">${pageBean.pageNum-2}</a>&nbsp</c:if>
        <c:if test="${pageBean.pageNum-1>0}"><a href="${pageContext.request.contextPath}/productListServlet?pageNum=${pageBean.pageNum-1}&condition=${pageBean.condition}">${pageBean.pageNum-1}</a>&nbsp</c:if>
        <a href="${pageContext.request.contextPath}/productListServlet?pageNum=${pageBean.pageNum}&condition=${pageBean.condition}">${pageBean.pageNum}</a>&nbsp
        <c:if test="${pageBean.pageNum+1<=pageBean.totalPageNum}"><a href="${pageContext.request.contextPath}/productListServlet?pageNum=${pageBean.pageNum+1}&condition=${pageBean.condition}">${pageBean.pageNum+1}</a>&nbsp</c:if>
        <c:if test="${pageBean.pageNum+2<=pageBean.totalPageNum}"><a href="${pageContext.request.contextPath}/productListServlet?pageNum=${pageBean.pageNum+2}&condition=${pageBean.condition}">${pageBean.pageNum+2}</a>&nbsp</c:if>
    </p>


    <p>
        第${pageBean.pageNum}页|共${pageBean.totalPageNum}页
    </p>
</div>
</body>
</html>
